package ru.ibrae.mchs.radiation.common.excelEntities;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class ExcelGSPos {

    private String name;
    private String sortFactor;
    private ArrayList<ExcelGeoobject> excelGeoobject = new ArrayList<ExcelGeoobject>();

    public ExcelGSPos(String name, String sortFactor) {
        this.name = name;
        this.sortFactor = sortFactor;
    }

    public String getName() {
        return name;
    }

    public String getSortFactor() {
        return sortFactor;
    }

    public ArrayList<ExcelGeoobject> getExcelGeoobject() {
        return excelGeoobject;
    }

    void sortGeoobjects() {
        Collections.sort(excelGeoobject, new Comparator<ExcelGeoobject>() {

            @Override
            public int compare(ExcelGeoobject o1, ExcelGeoobject o2) {
                return o1.getName().compareToIgnoreCase(o2.getName());
            }
        });
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof ExcelGSPos) {
            ExcelGSPos excelGSPos = (ExcelGSPos) obj;
            if (excelGSPos.getName().equalsIgnoreCase(this.getName())) {
                return true;
            }
        }
        return false;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0);
        hash = 53 * hash + (this.sortFactor != null ? this.sortFactor.hashCode() : 0);
        return hash;
    }

    public void doSorting() {
        Collections.sort(excelGeoobject, new Comparator<ExcelGeoobject>() {

            @Override
            public int compare(ExcelGeoobject o1, ExcelGeoobject o2) {
                return o1.getName().compareToIgnoreCase(o2.getName());
            }
        });
    }
}
